#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int fd = open("log.txt", O_CREAT | O_WRONLY | O_APPEND, 0666);
    if(fd < 0) exit(1);
    //库函数
    printf("hello printf\n");
    fprintf(stdout, "hello fprintf\n");
    const char *msg = "hello fwrite\n";
    fwrite(msg, strlen(msg), 1, stdout);
    //系统调用
    const char *msg1 = "hello write\n";
    write(1, msg1, strlen(msg1));
    
    fork();

    //close(1);
    //int fd = open("log.txt", O_CREAT | O_WRONLY | O_APPEND, 0666);
    //if(fd < 0) exit(1);

    //printf("fd : %d\n", fd);
    //printf("hello buffer\n");
    //printf("hello buffer\n");
    //printf("hello buffer\n");
    //printf("hello buffer\n");
    //fflush(stdout);
    //const char * msg = "HELLO BUFFER\n";
    //write(fd, msg, strlen(msg));

    //close(fd);
    return 0;
}
